<template>
  <component :is="currentComponent" :params="params" @on-ok="ok" @on-cancel="cancel" />
</template>
<script>
  export default {
    name: 'modal',
    data () {
      return {
        currentComponent: '',
        params: {},
        okCallback: null,
        cancelCallback: null
      }
    },
    methods: {
      create (component, ok, cancel, params) {
        this.$options.components.myComponent = component
        this.currentComponent = 'my-component'
        this.okCallback = ok
        this.cancelCallback = cancel
        this.params = params
      },
      ok (data) {
        if (this.okCallback !== null) {
          this.okCallback(data)
        }
      },
      cancel (data) {
        if (this.cancelCallback !== null) {
          this.cancelCallback(data)
        }
      }
    }
  }
</script>
